package main

import (
	"fmt"
	"regexp"
	"strconv"
	"strings"
)

func main() {
	src := `www.baidu.com : PING www.a.shifen.com (110.242.68.3) 56(84) bytes of data.
64 bytes from 110.242.68.3 (110.242.68.3): icmp_seq=1 ttl=251 time=9.96 ms`
	//解释正则表达式
	reg := regexp.MustCompile(`time=\d+\.\d+`)
	if reg == nil {
		fmt.Println("MustCompile err")
		return
	}
	//提取关键信息
	result := reg.FindString(src)
	arr := strings.Split(result, "=")
	if len(arr) == 2 {
		delayStr := arr[1]
		delayNum, err := strconv.ParseFloat(delayStr, 64)
		if err != nil {
			fmt.Println(err)
		}
		fmt.Println("delay : ", delayNum)
	}
}